package com.gj.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gj.mapper.SubsitutionMapper;
import com.gj.model.Subsitution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * author:guijie
 * date:${date}
 * description:TODO
 */
@Service
public class SubstitutionServiceImpl implements SubstitutionService {

    @Autowired
    private SubsitutionMapper subsitutionMapper;

    @Override
    public void insertSub(Subsitution subsitution) {
        subsitutionMapper.insert(subsitution);
    }

    @Override
    public boolean upd(String message) {
        String[] split = message.split(",");
        Long id = Long.valueOf(split[0]);
//        String houseName = split[1];
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("substitutionId",id);
//        Subsitution subsitution = subsitutionMapper.selectOne(wrapper);
//        subsitution.setHousename(houseName);
        Subsitution subsitution = new Subsitution();
        subsitution.setSubstitutionid(id);
        subsitution.setHousename(split[1]);
        int i = subsitutionMapper.update(subsitution,wrapper);
        return true;
    }
}
